home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / var / lib / dpkg / info / udev.preinst < prev    next >
Text File  |  2008-10-24  |  4KB  |  151 lines

  1. #!/bin/sh -e
  2. # This script can be called in the following ways:
  3. #
  4. # Before the package is installed:
  5. #    <new-preinst> install
  6. #
  7. # Before removed package is upgraded:
  8. #    <new-preinst> install <old-version>
  9. #
  10. # Before the package is upgraded:
  11. #    <new-preinst> upgrade <old-version>
  12. #
  13. #
  14. # If postrm fails during upgrade or fails on failed upgrade:
  15. #    <old-preinst> abort-upgrade <new-version>
  16.  
  17.  
  18. # Prepare to remove a no-longer used conffile
  19. prep_rm_conffile()
  20. {
  21.     CONFFILE="$1"
  22.  
  23.     if [ -e "$CONFFILE" ]; then
  24.         md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  25.         old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE '{s/ obsolete$//;s/.* //;p}}\" /var/lib/dpkg/status`"
  26.         if [ "$md5sum" != "$old_md5sum" ]; then
  27.             echo "Obsolete conffile $CONFFILE has been modified by you, renaming to .dpkg-bak"
  28.             mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
  29.     else
  30.         mv -f "$CONFFILE" "$CONFFILE".dpkg-obsolete
  31.     fi
  32.     fi
  33. }
  34.  
  35. # Prepare to move a conffile without triggering a dpkg question
  36. prep_mv_conffile() {
  37.     CONFFILE="$1"
  38.  
  39.     if [ -e "$CONFFILE" ]; then
  40.         md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  41.         old_md5sum="`sed -n -e \"/^Conffiles:/,/^[^ ]/{\\\\' $CONFFILE '{s/ obsolete$//;s/.* //;p}}\" /var/lib/dpkg/status`"
  42.         if [ "$md5sum" = "$old_md5sum" ]; then
  43.             mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
  44.     else
  45.             mv -f "$CONFFILE" "$CONFFILE".dpkg-moving
  46.         fi
  47.     fi
  48. }
  49.  
  50.  
  51. # Prepare to rename the persistent-disk.rules file
  52. prep_mv_persistent_disk_rules()
  53. {
  54.     prep_mv_conffile /etc/udev/rules.d/65-persistent-disk.rules \
  55.                  /etc/udev/rules.d/60-persistent-storage.rules
  56. }
  57.  
  58. # Prepare to rename the cdrom_id.rules file
  59. prep_mv_cdrom_id_rules()
  60. {
  61.     prep_mv_conffile /etc/udev/rules.d/50-cdrom_id.rules \
  62.                  /etc/udev/rules.d/30-cdrom_id.rules
  63. }
  64.  
  65. # Prepare to rename the upstream rules files
  66. prep_mv_upstream_rules()
  67. {
  68.     prep_mv_conffile /etc/udev/rules.d/00-init.rules \
  69.                  /etc/udev/rules.d/05-udev-early.rules
  70.     prep_mv_conffile /etc/udev/rules.d/65-persistent-input.rules \
  71.                  /etc/udev/rules.d/60-persistent-input.rules
  72.     prep_mv_conffile /etc/udev/rules.d/65-persistent-storage.rules \
  73.                  /etc/udev/rules.d/60-persistent-storage.rules
  74.     prep_mv_conffile /etc/udev/rules.d/65-persistent-storage-tape.rules \
  75.                  /etc/udev/rules.d/60-persistent-storage-tape.rules
  76.     prep_mv_conffile /etc/udev/rules.d/65-persistent-storage-edd.rules \
  77.                  /etc/udev/rules.d/61-persistent-storage-edd.rules
  78.     prep_mv_conffile /etc/udev/rules.d/99-udevmonitor.rules \
  79.                  /etc/udev/rules.d/95-udev-late.rules
  80. }
  81.  
  82.  
  83. # Prepare to remove the iftab.rules file
  84. prep_rm_iftab_rules()
  85. {
  86.     prep_rm_conffile /etc/udev/rules.d/25-iftab.rules
  87. }
  88.  
  89. # Prepare to remove early rules files
  90. prep_rm_early_rules()
  91. {
  92.     prep_rm_conffile /etc/udev/rules.d/05-udev-early.rules
  93. }
  94.  
  95. # Prepare to remove upstream rules files
  96. prep_rm_upstream_rules()
  97. {
  98.     prep_rm_conffile /etc/udev/rules.d/50-udev-default.rules
  99.     prep_rm_conffile /etc/udev/rules.d/80-drivers.rules
  100. }
  101.  
  102. # Prepare to remove the finish init script
  103. prep_rm_finish_init()
  104. {
  105.     prep_rm_conffile /etc/init.d/finish
  106. }
  107.  
  108.  
  109.  
  110. case "$1" in
  111.     install|upgrade)
  112.     # Upgrade from dapper
  113.     if dpkg --compare-versions "$2" lt "093-0ubuntu1"; then
  114.         prep_mv_persistent_disk_rules
  115.     fi
  116.  
  117.     # Upgrade within feisty development cycle
  118.     if dpkg --compare-versions "$2" lt "108-0ubuntu1"; then
  119.         prep_mv_cdrom_id_rules
  120.     fi
  121.  
  122.     # Upgrade from feisty
  123.     if dpkg --compare-versions "$2" lt "113-0ubuntu16"; then
  124.         prep_rm_iftab_rules
  125.  
  126.         # Upgrade from gutsy development version
  127.         prep_rm_finish_init
  128.     fi
  129.  
  130.     # Upgrade from gutsy
  131.     if dpkg --compare-versions "$2" lt "117-6"; then
  132.         prep_mv_upstream_rules
  133.         prep_rm_early_rules
  134.  
  135.         # Upgrade from hardy development version
  136.         prep_rm_upstream_rules
  137.     fi 
  138.     ;;
  139.  
  140.     abort-upgrade)
  141.     ;;
  142.  
  143.     *)
  144.     echo "$0 called with unknown argument \`$1'" 1>&2
  145.     exit 1
  146.     ;;
  147. esac
  148.  
  149.  
  150. exit 0
  151.